<div class="m-bg">
<h1>MySQL DATEDIFF() 函数</h1>
<h2>定义和用法</h2> <p>DATEDIFF() 函数返回两个日期之间的天数。</p> <h3><b>语法</b></h3> <div class="code notranslate"><pre><code class="language-sql"><div> DATEDIFF(date1,date2)</div></code></pre></div> <p>date1 和 date2 参数是合法的日期或日期/时间表达式。</p> <p><b>注释：</b>只有值的日期部分参与计算。</p> <h3><b>实例</b></h3> <p>下面是 SELECT 语句：</p> <div class="code notranslate"><pre><code class="language-sql"><div> SELECT DATEDIFF('2008-11-30','2008-11-29') AS DiffDate</div></code></pre></div> <p>结果如下所示：</p> <table class="reference notranslate">
<tr><th align="left">DiffDate</th></tr>
<tr><td>1</td></tr>
</table>
<h3><b>实例</b></h3> <p>下面是 SELECT 语句：</p> <div class="code notranslate"><pre><code class="language-sql"><div> SELECT DATEDIFF('2008-11-29','2008-11-30') AS DiffDate</div></code></pre></div> <p>结果如下所示：</p> <table class="reference notranslate">
<tr><th align="left">DiffDate</th></tr>
<tr><td>-1</td></tr>
</table>
<div class="text-center padding-10 margin-t-5">
</div>
</div>